package cn.ynu.cmrs.adapter;

import cn.ynu.cmrs.R;
import cn.ynu.cmrs.widget.RemoteImageView;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

/**
 * Adapter representing pictures of detail course
 * 
 * @author Yasha
 *
 */
public class GalleryAdapter extends BaseAdapter {
	
	Context mContext;
	/**
	 * URL of images
	 */
	private String[] imageUrl;

	public GalleryAdapter(Context cnt, String[] imageUrl) {
		this.mContext = cnt;
		this.imageUrl = imageUrl;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		if (imageUrl == null) {
			return 0;
		} else
			return imageUrl.length;
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		if (arg1 == null) {
			arg1 = LayoutInflater.from(mContext).inflate(R.layout.gallery_item,
					null);
		}
		RemoteImageView img = (RemoteImageView) arg1
				.findViewById(R.id.home_img);
		img.setImageUrl(imageUrl[arg0]);
		return arg1;
	}
}
